import axios from '../utils/request'

export interface LoginData {
    account: string
    password: string
}

export interface UserInfo {
    id: number
    username: string
    name: string
    role: string
}

export interface LoginResponse {
    token: string
    user_info: UserInfo
}

export const login = async (data: LoginData): Promise<LoginResponse> => {
    let res = await axios.post('/auth/login', data);
    return res.data;
}

export const getCurrentUser = async (): Promise<UserInfo> => {
    let res = await axios.get('/user/info');
    return res.data.data;
}